import { _decorator, Animation, Component } from 'cc';
import { GameModel } from '../Game/GameModel';
const { ccclass, property } = _decorator;

@ccclass('VisitorAni')
export class VisitorAni extends Component {
  @property(Animation)
  anim: Animation;
  curState: string;
  // complateHandler: CallBackHandler;
  outting: boolean;

  constructor() {
    super();
    this.curState = 'Visitor_out';
    this.outting = false;
  }

  playAni(ani: string, isStrong: boolean = false) {
    if (isStrong || this.curState != ani) {
      this.curState = ani;
      this.anim.stop();
      this.anim.play(this.curState);
      if (ani === 'Visitor_out') this.outting = true;
    }
  }

  complate() {
    switch (this.curState) {
      case 'Visitor_in':
        this.playAni('Visitor_standby');
        break;
      case 'Visitor_out':
        this.outting = false;
        GameModel.Ins().orderMac.refreshVisitorOrder();
        break;
    }
  }
}
